using System.Collections;
using System.Data;
using System.Web;
using System.Web.UI;

namespace PS.WebParts.Rollup
{
    public class RollUpDesignDataSourceView : RollUpDataSourceView
    { 
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            if (base.Lists != null && base.ListFieldNames != null && !string.IsNullOrEmpty(base.TopLevelSite))
                return base.ExecuteSelect(arguments);
            
            // DataSet ds = null;
            try
            {
                string[] fields = base.ListFieldNames;
                base.GetDataSet(  );
                for (int a = 1; a <= 10; a++)
                {
                    DataRow row = rollUpData.NewRow();
                    foreach (DataColumn column in rollUpData.Columns)
                    {
                        string s;
                        switch(column.ColumnName)
                        {
                            case "_ListTitle":
                                s = "List Title " +a;
                                break;
                            case "_ListUrl":
                                s = "/Lists/List"+a+ "/AllItems.aspx";
                                break;

                            case "_SiteTitle":
                                s = "Site Title";
                                break;
                            case "_SiteUrl":
                                s = "http://site/sites";
                                break;

                            case "_ItemId":
                                s = a.ToString();
                                break;

                            case "_ItemUrl":
                                s = "/lists/list/forms/dispform.aspx?id="+a;
                                break;
                                
                            case "_ItemEdit":
                                s = "/lists/list/forms/editform.aspx?id=" + a;
                                break;
                                
                            default:
                                s = column.ColumnName + a;
                                break;
                        }
                        
                        row[column] = s ;
                    }
                    rollUpData.Rows.Add(row);
                }
            }
            catch 
            {
            }

            return new DataView(base.rollUpData);
        }

        public RollUpDesignDataSourceView(HttpContext context, IDataSource owner, string viewName)
            : base(context, owner, viewName)
        {
            
        }
    }
}